<?php

namespace console\controllers;

use services\buss\ToolFileService;
use services\sys\SysFileService;
use Yii;
use yii\console\Controller;


class TempController extends Controller
{
    /**
     * 素材库图片调整，修复数据
     * php yii temp/repair-tool-data
     */
    public function actionRepairToolData()
    {
        try {
            $startTime = time();

            ToolFileService::repairData();

            $endTime = time();
            $diffTime = $endTime - $startTime;

            echo "success" . PHP_EOL;
            echo "开始时间: {$startTime}" . PHP_EOL;
            echo "结束时间: {$endTime}" . PHP_EOL;
            echo "本次耗时: {$diffTime}" . PHP_EOL;
        } catch (\Exception $e) {
            echo 'error: ' . $e->getMessage() . PHP_EOL;
        }
    }

    /**
     * 素材库生成缩略图
     * php yii temp/repair-tool-image
     */
    public function actionRepairToolImage()
    {
        try {
            $startTime = time();

            SysFileService::repairData();

            $endTime = time();
            $diffTime = $endTime - $startTime;

            echo "success" . PHP_EOL;
            echo "开始时间: {$startTime}" . PHP_EOL;
            echo "结束时间: {$endTime}" . PHP_EOL;
            echo "本次耗时: {$diffTime}" . PHP_EOL;
        } catch (\Exception $e) {
            echo 'error: ' . $e->getMessage() . PHP_EOL;
        }
    }
}
